iT邦幫忙

2021 iThome 鐵人賽

DAY 22
0

Drone CI/CD + Mattermost 組合技

雖然 drone plugins裡面沒有mattermost的plugin,但mattermost非常非常與slack可以相容,所以我們就找drone plugin for slack的來使用即可。

Drone Plugins Slack 說明頁

先將webhooks存到drone repo內的secret

https://ithelp.ithome.com.tw/upload/images/20210915/20115289sFvs1AHkB7.png

drone yml 設定檔案範例

簡單玩一下的版本

drone yaml 設定

kind: pipeline
name: ithome

steps:
- name: send mattermost notification
  when:
    branch: master
  image: plugins/slack
  settings:
    webhook:
      from_secret: my-webhook
    channel: gitea

mattermost channel內顯示
https://ithelp.ithome.com.tw/upload/images/20210928/20115289RVXlYDz6HT.png

設定username

drone yaml 設定

kind: pipeline
name: ithome

steps:
- name: send mattermost notification
  when:
    branch: master
  image: plugins/slack
  settings:
    webhook:
      from_secret: my-webhook
    channel: gitea
    username: ithome-use

mattermost channel內顯示
https://ithelp.ithome.com.tw/upload/images/20210928/201152890QFVtPhrsF.png

設定圖示

drone yaml 設定

kind: pipeline
name: ithome

steps:
- name: send mattermost notification
  when:
    branch: master
  image: plugins/slack
  settings:
    webhook:
      from_secret: my-webhook
    channel: gitea
    username: ithome-use
    image_url: https://unsplash.it/256/256/?random

mattermost channel內顯示
https://ithelp.ithome.com.tw/upload/images/20210928/20115289k8yooPmqNk.png

使用自訂模板

drone yaml 設定

kind: pipeline
name: ithome

steps:
- name: send mattermost notification
  when:
    branch: master
  image: plugins/slack
  settings:
    webhook:
      from_secret: my-webhook
    channel: gitea
    username: drone
    template: >
       【溫馨提醒】分支: {{build.branch}},異動者: {{build.author}} 更版動作開始 {{build.link}} !!

mattermost channel內顯示
https://ithelp.ithome.com.tw/upload/images/20210928/20115289T3H7RZK7IN.png

小結

今日練習是不是很簡單呢?這方法可以用在當你在CI/CD有任何問題或執行成功時,可以透過這個plugin將訊息推送到你的mattermost channel很方便吧~


上一篇
[Day 21] Mattermost - RSS
下一篇
[Day 23] Mattermost - ChatOps
系列文
Dev's Ops 啟程30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言